﻿
using System.Collections.Generic;
using DevExpress.XtraTreeList;
using DevExpress.XtraTreeList.Nodes;
using HuaCheng.DataAccess;
namespace HuaCheng.Controller
{
    public class AllocationControl
    {
        /// <summary>
        /// 根据配置列表生成TreeList
        /// </summary>
        /// <param name="stepList"></param>
        /// <param name="treeList"></param>
        /// <returns></returns>
        public static TreeList SetTreeListByAlloList(List<Dicts> alloList, TreeList treeList)
        {
            treeList.ClearNodes();
            //遍历工步信息列表
            for (int i = 0; i < alloList.Count; i++)
            {
                Dicts dicAllo = alloList[i];
                treeList = SetTreeListNodeByAllo(dicAllo, treeList, i);
            }
            return treeList;
        }
        /// <summary>
        /// 根据Allocation对象生成TreeList节点
        /// </summary>
        /// <param name="slopeStep"></param>
        /// <param name="treeList"></param>
        /// <param name="i"></param>
        /// <returns></returns>
        private static TreeList SetTreeListNodeByAllo(Dicts dicAllo, TreeList treeList, int i)
        {
            //新增节点
            TreeListNode tmpNode = treeList.Nodes.Add();
            tmpNode["Code"] = dicAllo.Code;
            tmpNode["Description"] = dicAllo.Name;
            treeList.SetNodeIndex(tmpNode, i);
            return treeList;
        }
    }
}
